<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div>
        <input type="checkbox" value="dog">狗
        <input type="checkbox" value="cat">猫
        <input type="checkbox" value="mouse">鼠
    </div>
    <p></p>
</body>
<script type="text/javascript">
    var input = document.querySelectorAll('input');
    var p = document.querySelector('p');
    var div = document.querySelector('div');
    div.addEventListener('click', dog);

    function dog() {
        var len = input.length;
        let string = '';
        for (let i = 0; i < len; i++) {
            if (input[i].checked) {
                string += (input[i].nextSibling.nodeValue).trim() + ' ';
                console.log(string);
            }
        }
        p.innerText = string;
    }

</script>

</html>